package cloud.xlh.auth.controller;

import cloud.xlh.auth.domin.dto.UserInfoDTO;
import cloud.xlh.auth.service.LoginService;
import cloud.xlh.auth.service.VerifyService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/2/8 9:58
 * @ Description:
 */
@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private LoginService loginService;
    @Autowired
    private VerifyService verifyService;

    /**
     * 登录
     */
    @RequestMapping("/login")
    public JSONObject login(@RequestBody UserInfoDTO userInfoDTO, HttpServletRequest request, HttpServletResponse response) {
        return loginService.login(userInfoDTO, request, response);
    }

    /**
     *
     * @param jsonObject
     * @return boolean
     * @author XuLeHuang
     * @create 2023/2/8
     * @name: token校验
     * @Description:
     **/
    @RequestMapping("/verifyToken")
    public boolean verify(@RequestBody JSONObject jsonObject) {
        return verifyService.verifyToken(jsonObject);
    }


    /**
     *
     * @param jsonObject
     * @return com.alibaba.fastjson.JSONObject
     * @author XuLeHuang
     * @create 2023/2/8
     * @name: 发送短信
     * @Description:
     **/
    @RequestMapping("/sendMessage")
    public JSONObject sendMessage(@RequestBody JSONObject jsonObject) {
        return verifyService.sendMessage(jsonObject);
    }
}
